<template>
  <div class="filter-param">
    <div class="webheart classbox">
      <div class="class-wrap clearfix">
        <p class="fl class-titile">资源标签：</p>
        <div :class="['fl', 'className', 'acitve' + type]">
          <p :class="{ acitve: labelActive == '' }" @click="handleLabel()">
            全部
          </p>
          <p
            :class="{ acitve: labelActive == v.id }"
            v-for="v in labelData"
            :key="v.id"
            @click="handleLabel(v.id)"
          >
            {{ v.name }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { openApiSysLabelQuery } from "@/api/openApi";
import { LIBRARY } from "@/utils/config.js";
import courseCreate from "@/mixins/courseCreate";
export default {
  mixins: [courseCreate],
  data() {
    return {
      type: this.$route.meta.type,
      curLibrary: {},
      labelActive: "",
      labelData: [],
    };
  },
  watch: {
    $route() {
      this.type = this.$route.meta.type;
      this.curLibrary = LIBRARY.filter((v) => v.type == this.type)[0];
      this.getList();
    },
  },
  mounted() {
    this.curLibrary = LIBRARY.filter((v) => v.type == this.type)[0];
    this.getList();
  },
  methods: {
    getList() {
      openApiSysLabelQuery({ type: this.type, labelType: 2 }).then((res) => {
        this.labelData = res.data.data;
      });
    },
    handleLabel(v) {
      this.labelActive = v || "";
      this.$bus.$emit("e-knowledgeList", { labelValue: v });
    },
  },
};
</script>
<style scoped lang="scss">
.filter-param {
  width: 100%;
  padding-top: 55px;
  padding-bottom: 10px;
  background: #f3f9fa;
  .classbox {
    .class-wrap {
      position: relative;
      width: 100%;
      .class-titile {
        position: absolute;
        left: 0;
        top: 0;
        margin-right: 10px;
        margin-top: 5px;
        font-size: 18px;
        color: #333;
        font-weight: bold;
      }
      .className {
        padding-left: 8%;
        width: 92%;
        text-align: center;
        p {
          float: left;
          min-width: 50px;
          text-align: center;
          height: 30px;
          line-height: 30px;
          padding: 0 10px;
          font-size: 16px;
          color: #333;
          margin-right: 20px;
          border: 0 none;
          border-radius: 5px;
          cursor: pointer;
          margin-bottom: 15px;
          transition: all 0.3s;
          &:hover,
          &.acitve {
            background: #06a2c9;
            color: #fff;
          }
        }
      }
      .acitve1 {
        p {
          &:hover,
          &.acitve {
            background: #06a2c9;
            color: #fff;
          }
        }
      }
      .acitve2 {
        p {
          &:hover,
          &.acitve {
            background: #0659a7;
            color: #fff;
          }
        }
      }
      .acitve3 {
        p {
          &:hover,
          &.acitve {
            background: #3d815a;
            color: #fff;
          }
        }
      }
      .acitve4 {
        p {
          &:hover,
          &.acitve {
            background: #e67c00;
            color: #fff;
          }
        }
      }
      .acitve5 {
        p {
          &:hover,
          &.acitve {
            background: #cc8690;
            color: #fff;
          }
        }
      }
    }
  }
}
</style>